using UnityEngine;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;

// 移动主角到指定Transform位置
public class MoveTo : Action
{
    public float speed = 0;
    public SharedTransform target;

    public override void OnStart(){
        Debug.Log("打印1");
    }

    public override TaskStatus OnUpdate()
    {
        Debug.Log("打印3");
        if (Vector3.SqrMagnitude(transform.position - target.Value.position) < 0.1f) {
            return TaskStatus.Success;
        }
        transform.position = Vector3.MoveTowards(transform.position, target.Value.position, speed * Time.deltaTime);
        return TaskStatus.Running;
    }

    public override void OnEnd(){
        Debug.Log("打印2");
    }

}